import pandas as pd
pd.set_option('display.unicode.east_asian_width',True)
df = pd.read_excel('互联网广告智能投放数据.xlsx')
df['投放时间']=pd.to_datetime(df['投放时间']).df.hour
df1=df.groupby('渠道').agg({'价格(元)':'sum'})
df1['排名']=df1.rank(method='first',ascending=False)
df1.sort_values(by='排名',ascending=True,inplace=False)
df2=pd.crosstab(index=df['渠道'],columns=df['是否点击'],margins_name='比例',margins=True,normalize=True)
print('渠道和是否点击的交叉表:\n,df2')
df3=df[['年龄层次','城市等级','价格(元)','投放时间']]
print(df3.corr())